package com.teamtgv.shareshark;

import java.util.List;

import com.teamtgv.shareshark.R;
import com.facebook.Request;
import com.facebook.Response;
import com.facebook.Session;
import com.facebook.model.GraphUser;


import android.annotation.SuppressLint;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.TextView;

@SuppressLint("NewApi")
public class SelectionFragment extends Fragment {

	TextView v;
	
	@Override
	public View onCreateView(LayoutInflater inflater, 
	        ViewGroup container, Bundle savedInstanceState) {
	    super.onCreateView(inflater, container, savedInstanceState);
	    View view = inflater.inflate(R.layout.activity_selection_fragment, 
	            container, false);
	   v = (TextView) view.findViewById(R.id.textView2);
	    Button b = (Button) view.findViewById(R.id.button1);
	    	b.setOnClickListener(new View.OnClickListener() {
	            @Override
	            public void onClick(View view) {
	              Session s = Session.getActiveSession();
	              requestFacebookFriends(s);

	            }
	        });
	    
	    
	    return view;
	}
	
	private void requestFacebookFriends(Session session) {
	    Request.executeMyFriendsRequestAsync(session,
	            new Request.GraphUserListCallback() {
	          

					@Override
					public void onCompleted(List<GraphUser> users,
							Response response) {
						v.setText(users.get(0).getName() +", " + users.get(1).getName()+", " + users.get(2).getName());	
					}
	            });
	}
	

}
